using System;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Text;
using NUnit.Framework;
using OutlookSocialProvider;

namespace OSC.Base.Tests
{
    [TestFixture]
    public class OSCProviderBaseTest
    {
        private ISocialProvider m_Provider;

        [SetUp]
        public void SetUp()
        {
            m_Provider = new DummyOSCProviderBase();
        }

        [Test]
        public void TestGetCapabilities_ReturnsDefaultCapabilities()
        {
            var capabilities = m_Provider.GetCapabilities();
            var executingAssembly = Assembly.GetExecutingAssembly();
            var stream = executingAssembly.GetManifestResourceStream(executingAssembly.GetName().Name + ".capabilities.xml");
            var expectedXml = new StreamReader(stream).ReadToEnd();
            Assert.AreEqual(expectedXml, capabilities, "capabilities do not match the expected default capabilities");
        }

        //TODO: test provider properties

        [Test]
        public void TestGetAutoConfiguredSession_ThrowsNotSupportedException()
        {
            try
            {
                m_Provider.GetAutoConfiguredSession();
                Assert.Fail();
            }
            catch (NotSupportedException) { }
        }
        [Test]
        public void TestGetStatusSettings_ThrowsNotSupportedException()
        {
            try
            {
                string arg1;
                int arg2;
                m_Provider.GetStatusSettings(out arg1, out arg2);
                Assert.Fail();
            }
            catch (NotSupportedException) { }
        }
        [Test]
        public void TestLoad_SetsSocialSession()
        {
            m_Provider.Load("foo", "foo");
            var session = m_Provider.GetSession();
            Assert.IsNotNull(session);
        }
    }
}